package com.pajk.user.model;

import com.pajk.user.model.enums.Gender;
import com.pajk.user.model.enums.RelationType;

import java.io.Serializable;
import java.util.Date;

/**
 * Created by peide.zhang on 4/28/14.
 */
public class UserRelation extends Entity
        implements Serializable{

    private Long followerId;
    private Long followeeId;
    private String nick;
    private RelationType type;
    private String access;
    private String appFrom;

    public UserRelation(){}

    public UserRelation(Long followerId, Long followeeId, RelationType type, String nick, String access,String appFrom){
        this.followeeId = followeeId;
        this.followerId = followerId;
        this.type = type;
        this.access = access;
        this.nick = nick;
        this.access = appFrom;
    }

    public Long getFollowerId() {
        return followerId;
    }

    public void setFollowerId(Long followerId) {
        this.followerId = followerId;
    }

    public Long getFolloweeId() {
        return followeeId;
    }

    public void setFolloweeId(Long followeeId) {
        this.followeeId = followeeId;
    }

    public String getNick() {
        return nick;
    }

    public void setNick(String nick) {
        this.nick = nick;
    }

    public RelationType getType() {
        return type;
    }

    public void setType(RelationType type) {
        this.type = type;
    }

    public String getAccess() {
        return access;
    }

    public void setAccess(String access) {
        this.access = access;
    }

    public String getAppFrom() { return appFrom;  }

    public void setAppFrom(String appFrom) {  this.appFrom = appFrom;  }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        UserRelation that = (UserRelation) o;

        if (access != null ? !access.equals(that.access) : that.access != null) return false;
        if (followeeId != null ? !followeeId.equals(that.followeeId) : that.followeeId != null) return false;
        if (followerId != null ? !followerId.equals(that.followerId) : that.followerId != null) return false;
        if (nick != null ? !nick.equals(that.nick) : that.nick != null) return false;
        if (type != that.type) return false;
        if (appFrom != that.appFrom) return false;
        return true;
    }

    @Override
    public int hashCode() {
        int result = followerId != null ? followerId.hashCode() : 0;
        result = 31 * result + (followeeId != null ? followeeId.hashCode() : 0);
        result = 31 * result + (nick != null ? nick.hashCode() : 0);
        result = 31 * result + (type != null ? type.hashCode() : 0);
        result = 31 * result + (access != null ? access.hashCode() : 0);
        result = 31 * result + (appFrom != null ? appFrom.hashCode() : 0);
        return result;
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("UserRelation{");
        sb.append("followerId=").append(followerId);
        sb.append(", followeeId=").append(followeeId);
        sb.append(", nick='").append(nick).append('\'');
        sb.append(", type=").append(type);
        sb.append(", appFrom=").append(appFrom);
        sb.append(", access='").append(access).append('\'');
        sb.append('}');
        return sb.toString();
    }
}
